package com.gitee.jmash.oidc.client.web.controller;

import java.io.IOException;
import com.gitee.jmash.oidc.client.web.OauthUtil;
import jakarta.enterprise.context.RequestScoped;
import jakarta.mvc.Controller;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Context;

/** Oauth login View. */
@Path("/authlogin")
@Controller
@RequestScoped
public class AuthLoginController {


  @GET
  public String execute(@Context HttpServletRequest req, @Context HttpServletResponse resp)
      throws IOException {
    String responseType = req.getParameter("response_type");
    String url = OauthUtil.createAuthUrl(req, "sample/authcode", responseType, false);
    resp.sendRedirect(url);
    return null;
  }

}
